$OpenBSD: patch-src_libjasper_base_jas_seq_c,v 1.1 2008/05/17 09:32:16 espie Exp $
--- src/libjasper/base/jas_seq.c.orig	Fri Jan 19 22:43:05 2007
+++ src/libjasper/base/jas_seq.c	Fri May 16 21:13:18 2008
@@ -114,7 +114,7 @@ jas_matrix_t *jas_matrix_create(int numrows, int numco
 	matrix->datasize_ = numrows * numcols;
 
 	if (matrix->maxrows_ > 0) {
-		if (!(matrix->rows_ = jas_malloc(matrix->maxrows_ *
+		if (!(matrix->rows_ = jas_alloc2(matrix->maxrows_,
 		  sizeof(jas_seqent_t *)))) {
 			jas_matrix_destroy(matrix);
 			return 0;
@@ -122,7 +122,7 @@ jas_matrix_t *jas_matrix_create(int numrows, int numco
 	}
 
 	if (matrix->datasize_ > 0) {
-		if (!(matrix->data_ = jas_malloc(matrix->datasize_ *
+		if (!(matrix->data_ = jas_alloc2(matrix->datasize_,
 		  sizeof(jas_seqent_t)))) {
 			jas_matrix_destroy(matrix);
 			return 0;
@@ -220,7 +220,7 @@ void jas_matrix_bindsub(jas_matrix_t *mat0, jas_matrix
 	mat0->numrows_ = r1 - r0 + 1;
 	mat0->numcols_ = c1 - c0 + 1;
 	mat0->maxrows_ = mat0->numrows_;
-	mat0->rows_ = jas_malloc(mat0->maxrows_ * sizeof(jas_seqent_t *));
+	mat0->rows_ = jas_alloc2(mat0->maxrows_, sizeof(jas_seqent_t *));
 	for (i = 0; i < mat0->numrows_; ++i) {
 		mat0->rows_[i] = mat1->rows_[r0 + i] + c0;
 	}
@@ -432,7 +432,8 @@ int jas_seq2d_output(jas_matrix_t *matrix, FILE *out)
 	for (i = 0; i < jas_matrix_numrows(matrix); ++i) {
 		for (j = 0; j < jas_matrix_numcols(matrix); ++j) {
 			x = jas_matrix_get(matrix, i, j);
-			sprintf(sbuf, "%s%4ld", (strlen(buf) > 0) ? " " : "",
+			snprintf(sbuf, sizeof sbuf, 
+			    "%s%4ld", (strlen(buf) > 0) ? " " : "",
 			  JAS_CAST(long, x));
 			n = strlen(buf);
 			if (n + strlen(sbuf) > MAXLINELEN) {
@@ -440,7 +441,7 @@ int jas_seq2d_output(jas_matrix_t *matrix, FILE *out)
 				fputs("\n", out);
 				buf[0] = '\0';
 			}
-			strcat(buf, sbuf);
+			strlcat(buf, sbuf, sizeof buf);
 			if (j == jas_matrix_numcols(matrix) - 1) {
 				fputs(buf, out);
 				fputs("\n", out);
